﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="xDefault.aspx.cs" Inherits="UIDocument.xDefault" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="http://localhost:5864/JavaScript/jquery.js" type="text/javascript"></script>
    <script src="JavaScript/jquery.blockUI.js" type="text/javascript"></script>
    <style type="text/css">
     .style1 {
width: 660px;
border: 1px solid #dbdbdb;
margin-left: 10%;
margin-top: 20%;
}
.title {
background: url(UIDocument/Image/bg_boxtitle.jpg) left top repeat-x #025ba5;
text-align: center;
color: #fff;
font-size: 1.8em;
padding: 5px 0;
margin-bottom: 0;
}
        #btnlogin
        {
            width: 125px;
        }
        .errorBox {
display: none;
margin: 5px;
padding: 5px;
border: 1px solid #dbdbdb;
text-align: left;
border-radius: 5px;
background: url(Image/error-icon.gif) 0 3px no-repeat #EBEBEB;
}
#divloader
{
   border:1px solid red ;
   background-color:#EBEBEB;
   text-align :center;
}
    </style>
   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%if (loginVisible == true)
  { %>
  <div>
  <img src ="Image/login.jpg" />
  </div>
    <table class="style1" id ="login">
     <tr>
     
     <td colspan ="2">
    <div class="title" style="margin-bottom:20px;">Login</div>
    
    <div class ="errorBox">  <p>Your UserId or Password is not valid !!!</p></div>
    
     <table style =" margin-left :20%;" >
     <tr>
            <td>
            
            <span><strong>&nbsp;&nbsp; Enter User Id : </strong> </span>
               </td>
            <td style =" padding:5px;"><span><strong>
                <input type="text" name="txtuserid" id ="txtuserid" value="" 
                    style="width: 186px; margin-bottom: 0px; width: 200px; height: 32px; font-size:30px;" /></strong></span>  </td>
        </tr>
        <tr>
            <td style =" padding:5px;">
            <span><strong>Enter Password : </strong> </span></td>
            <td style ="padding:5px;">
                <input type="password" name="txtpassword" id ="txtpassword" value=""  style="width: 200px; height: 32px;font-size:30px;" /></td>
        </tr>
        <tr>
            <td colspan ="2">
            <span style =" margin-left:30%; padding :20px;"><strong>
                <input type="button" name="btnlogin" id ="btnlogin" value="Login" 
                    style =" margin-left:20px; height:31px;" /><%if (logout)
                                                                    {  logout = false;%> <div id ="divloader"> Logout Successfully...</div> <%}%>
                                                                                       </strong> </span>  &nbsp;</td>
           
        </tr>
    </table>
     </td>
        </tr>
       </table>
       
    <%} %>

    <script type ="text/javascript">

        $(document).ready(function () {

            $("#txtpassword").keypress(function (e) {

                if (e.keyCode == 13) {
                    login();
                }
            });


            $("#btnlogin").click(function () {
                login();
            });
            function login() {
                debugger;
                var userid = $("#txtuserid").val();
                var password = $("#txtpassword").val();
                if (userid != "" && password != "") {
                    $(document).ajaxStart(function () {
                        $('#login').block({ message: '<p><img src="Image/processBar.gif" />Please Wait</p>',
                            css: { border: '3px solid #a01' }
                        });
                    }).ajaxStop(function () {
                        $("#login").unblock();
                    });
                    $.ajax({

                        url: "WebForm3.aspx/Login",
                        type: "POST",
                        data: '{"userid":"' + userid + '" , "password":"' + password + '"}',
                        dataType: "json",
                        contentType: "application/json",
                        success: function (_data) {

                            if (_data.d.Data == true) {

                                window.location.href = "xDefault.aspx";

                            } else {

                                $("div.errorBox").css("display", "block");
                                $("#divloader").css("display", "none");
                            }
                        },
                        error: function (a, b, c) { alert(c); }
                    });


                }
            }
        });


       
    </script>
   
</asp:Content>
